#ifndef MAPFILTER_ZWK_H
#define MAPFILTER_ZWK_H

#include<iostream>
#include<vector>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/core/core.hpp>
#include<unordered_map>
#include<list>
#include<queue>
#include<opencv2/imgproc/imgproc.hpp>
#include<string>
#include<iostream>

using namespace std;
using namespace cv;

struct Point2D
{
    Point2D() {}
    Point2D(int x_,int y_)
    {
        x=x_;
        y=y_;
    }
    int x;
    int y;
};


struct ConnectedEdge
{
    ConnectedEdge() {}
    list<Point2D> points;
};


class MapFilter_Zwk
{
public:
    MapFilter_Zwk();
    ~MapFilter_Zwk();
    void runMapFilter(Mat &oriImg, Mat &optImg);

private:
    bool hasValidDirection(const Mat& img,int x,int y);
    ConnectedEdge* BFS(const Mat& img,const Point2D &initPoint, int initPixelVale,unordered_map<int,bool>& isVisited,int stopPixelValue=0,int maxGrayNums=8,bool isLimited=false );
    void getBinaryImage(Mat &oriImg,Mat &binaryImg);
    void removeLittleColorRegion(Mat& oriImg,Mat& optImg,int colorType);
    void removeIsolatedBlackPoint(Mat &oriImg, Mat &optImg);
    void removeWitheCircleGray(Mat &oriImg, Mat &binaryImg, Mat &optImg);
    void removeInvalidBlackPoint(Mat &oriImg, Mat &optImg);
    int BLACK;
    int WHITE;
    int GRAY;
    int OTHER;

    int inflate_num;
    int min_area;
    int max_area;
    int maxLimitedNum_black;
    int maxLimitedNum_white;
};
#endif // MAPFILTER_ZWK_H